
const Goods = { template: `
<div>
       
<mt-header :title="'第'+area+'区物料查询'" ></mt-header>
<mt-cell title="刷新数据" label="同步数据库信息">  <mt-button size="small" icon="success"  type="primary" @click="refresh()"> 执行</mt-button></mt-cell>
<div v-for = "(item, i) in goods">
    <mt-cell :title="item.doc_name" :label="room +'-'+area+'区 '+(getColumn(item.area, item.column)+1)+'列'+(item.layer+1)+'层'+(item.section+1)+'节'"></mt-cell>
 
</div>

  <br/>
    <p v-text="get" >12</p>
         <br/> <br/>
         <br/> <br/>
         <br/>

</div>
`,
    data: function () {
        return {
            area:this.$route.params.area,
            room:this.$route.params.room,
            goods:[],
            data:value,
            get:123,
        }
    },

    
   created () {
       this.$parent.bar_show = true;
       this.fetchData();
      
   },
  methods:
  {
    getColumn(area, index){
        for(let i=0; i<this.data.cabinets.item.length; ++i){

            if(this.data.cabinets.item[i].area == area && this.data.cabinets.item[i].index == index){
                return i;
            }
        }
        return -1;//this.data.cabinets.item[index].index;
    },
    fetchData () {
        var self = this;
        axios.get("/geek/"+this.room+"/"+this.area+"/setupTable",
        {
        }).then(function(res){
            
            self.data = res.data;
            self.reload();
            
        }).catch(function (error) {
            alert(error);
        });
    },
    refresh(){
        Vue.$indicator.open();
        let self = this;
        axios.get("/geek/"+this.room+"/"+this.area+"/archives/preprocessed",
        {
        }).then(function(res){
            setTimeout(function(){self.reload()},100);
        }).catch(function (error) {
            console.log(error);
            Vue.$indicator.close();
        });
    }, 
    reload(){

        Vue.$indicator.open();
        let self = this;
        let url = "/geek/"+this.room+"/"+this.area+"/archives?";
        this.get = self.data;
        for(let n =0 ;n<self.data.cabinets.areas.length; ++n){
            url += "area="+self.data.cabinets.areas[n]+'&';
        }
        axios.get(url,
        {
       
        }).then(function(res){
            //self.get = res.data;
            self.goods = res.data;
           // alert(self.goods.length)
            Vue.$indicator.close();
        }).catch(function (error) {
            console.log(error);
            Vue.$indicator.close();
        });
    },
   
   
   
  },

}
